package com.tedu.api;


import org.junit.Test;

public class 作业 {

//[ ] 1.输出字符串"HelloJava"的字符串长度  10

    // String str = "HelloJava";
    //   int length = str.length();
    //   System.out.println(length);


//2.输出字符串"HelloJava"的字
//4.7

    //3.输出"HelloJava"中下标为5处开始第一次出现以"o"的位置
    public class Main {
        public static void main(String[] args) {
            String str = "HelloJava";
            String subStr = str.substring(0, 5);
            System.out.println(subStr);
        }
    }


    //- [ ] 4.截取"HelloJava"中"Hello"并输出
    public class Main1 {
        public static void main(String[] args) {
            String str = "HelloJava";
            int startIndex = str.indexOf("Java");
            String subStr = str.substring(startIndex);
            System.out.println(subStr);
        }
    }


    //- [ ] 5.截取"HelloJava"中"Java"并输出

    //s = "  Hello  "

    //   s = s.strip()

    // print(s);


    //6.将字符串" Hello "中两边的空白去掉后输出
    @Test
    public void testTrim() {
        String str = " Hello ";//后台传入前后都加空格，xD4e
        //后台传入前台字符串---一律去空格
        str = str.trim();
        System.out.println("去掉空格" + str);


//- [ ] 7.输出"HelloJava"中第6个字符"J"
       // String str = "HelloJava";
        char sixthChar = str.charAt(5);
        System.out.println(sixthChar);


//- [ ] 8.将"HelloJava"转换为小写，然后转换为大写
        public void testTrim1() {
            String str="HelloJava";
            str=str.trim().toLowerCase();
            System.out.println("小写"+str);
            str=str.toUpperCase();
            System.out.println("大写"+str);
        }

    }

}

